home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- ** DebugMacros.h
- **
- ** Copyright ©1996, Symantec Corp. and Glenn L. Austin
- ** All rights reserved worldwide
- *******************************************************************************/
-
- #pragma once
-
- static char* __debugFileName = __FILE__;
-
- static void* __newmalloc(size_t sz, char* fileName, long lineNumber)
- {
- char* p = (char*) malloc(sz + sizeof(char*) + sizeof(long));
-
- *(char**) p = fileName;
- *(sizeof(char*) + p) = lineNumber;
-
- return (void*) (sizeof(char*) + sizeof(long) + p);
- }
-
- #define __GetRealPtr(p) ((void*) ((char*) p - sizeof(char*) - sizeof(long))
-
- #define MALLOC(sz) __newmalloc(sz, __debugFileName, __LINE__)
- #define CALLOC(sz1,num) __newmalloc(sz1 * num, __debugFileName, __LINE__)
- #define REALLOC(p, sz) realloc(__GetRealPtr(p), sz + sizeof(char*) + sizeof(long))
- #define FREE(p) free(__GetRealPtr(p))